@isTest
private class CMRGroupIdHandlerTest {
  private static ID curAccId1;
  private static ID curAccId2;

  private static list<ID> memberUserIds;
  private static User admin_user;
  private static UserTeamMember utm;
  
  private static void init(){
    User u_admin = new User();
    u_admin = new User();
    u_admin.UserName = 'admin_xyz_1234567890@atti-temp.com';
    u_admin.LastName = 'admin Test Email';
    u_admin.Email = 'admin_xyz_1234567890@atti.com';
    u_admin.Alias = 'adminxxx';
    u_admin.CommunityNickname = 'admin_xyaz_1234556';
    u_admin.TimeZoneSidKey = 'America/Los_Angeles';
    u_admin.LocaleSidKey = 'en_US';
    u_admin.EmailEncodingKey = 'UTF-8';
    u_admin.ProfileId = [select ID from Profile where Name = 'System Administrator' limit 1].Id;
    u_admin.UserRoleId = [select ID from UserRole where Name like 'Information Systems'limit 1].Id;
    u_admin.LanguageLocaleKey = 'en_US';
    u_admin.IsActive = true;
    Database.Saveresult s_sr_admin = Database.insert(u_admin);
    admin_user = [select id from User where id =: s_sr_admin.getId() limit 1];
    
   
    
    Account acct1 = new Account();
    acct1.Name = 'Test CMR Account 1';
    acct1.OwnerId = admin_user.id;
    
    acct1.RecordTypeId = RecordTypeHelper.GetRecordTypeId('Account', 'CMR Group');
    system.debug('************************************************>');
    System.runAs(admin_user){
      Database.Saveresult sr1 = Database.insert(acct1); 
      curAccId1 = sr1.getId();
    }
    system.debug('<************************************************');
    Account acct2 = new Account();
    acct2.Name = 'Test CMR Account 2';
    acct2.OwnerId = admin_user.id;
    
    acct2.RecordTypeId = RecordTypeHelper.GetRecordTypeId('Account', 'CMR Group');
    System.runAs(admin_user){
      Database.Saveresult sr1 = Database.insert(acct2); 
      curAccId2 = sr1.getId();
    }
    
    acct1 =  [select id, CMR_Group_ID__c, RecordType.Name from account where id = :curAccId1];
    acct2 =  [select id, CMR_Group_ID__c, RecordType.Name from account where id = :curAccId2];
    
    system.debug(acct1.CMR_Group_ID__c);
    system.debug(acct2.CMR_Group_ID__c);
    system.assertNotEquals(integer.valueof(acct1.CMR_Group_ID__c), 0);
    system.assertNotEquals(integer.valueof(acct2.CMR_Group_ID__c), 0);
    system.assertNotEquals(acct1.CMR_Group_ID__c, acct2.CMR_Group_ID__c);

  }
  
  public static testMethod void testCMRAccountAdd() {
    init();
    
  }

}